﻿@using Cnm.Models
@using Cnm.Mvc.Web.Infrastructure
@using Kendo.Mvc.UI
@model Cnm.Models.ViewModels.PostConditionViewModel

@(Html.Kendo().Grid<Post>()
    .Name(Guid.NewGuid().ToString())
        .HtmlAttributes(new { @class = "grid-no-header" })
    .Columns(columns =>
    {
        columns.Template(e => { }).ClientTemplate(" ").Width(130);
        columns.Template(e => { }).ClientTemplate(" ");
        columns.Template(e => { }).ClientTemplate(" ").Width(130);
    })
    .ClientRowTemplate(
        "<tr data-uid='#: uid #'>" +
            "<td class='photo'>" +
                "<a href='#:UrlDetails#'>" +
                   "<img src='" + Url.Content(WebManager.PostImageThumbFolderPath) + "#:data.ImageName#' alt='#: data.ImageName #' />" +
                   "</a>" +
            "</td>" +
            "<td class='details'>" +
                "<h5><a href='#:UrlDetails#'>#:data.Name#</a></h5>" +
                    "<p><span>#:data.PriceString# đ</span></p>" +
                "<p>" +
                        "<a href='#:data.Category.UrlDetails#'><span class='label label-default'>#:data.Category.Name#</span></a>" +
                        "<a href='#:data.Region.UrlDetails#'><span class='label label-info'>Ở #:data.Region.Name#</span></a>" +
                "</p>" +
            "</td>" +
                "<td class='time-Ago text-right'>" +
                "#: TimeAgo #" +
            "</td>" +
         "</tr>"
    )
            .Pageable(pageable => pageable
                .Refresh(true)
                .PageSizes(true)
                .ButtonCount(5))
    .DataSource(dataSource => dataSource
        .Ajax().Read(read => read.Action("GetPosts", "Ref", new
            {
                titularId = Model.TitularId,
                categoryId = Model.CategoryId,
                regionId = Model.RegionId,
                postTypeId = Model.PostTypeId,
                itemStatusId = Model.ItemStatusId,
                keyword = Model.Keyword
            }))
    )
)